<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class="app-container">
    <el-form id="mvcfm">
      <el-row>
        <el-col :span="10" :xs="24">
          <div class="form-unit">
            <span class="mvc-title-left">
              {{s_search.title}}
            </span>
          </div>
          <div>
          </div>
          <el-select @change="list_s_year" v-model="s_search.CMIDSEL1">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in s_year" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select>
          <el-select @change="list_s_month" v-model="s_search.CMIDSEL2">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in s_month" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select>
          <table id='calendarTable' cellspacing="0" border="0" class='el-table el-table--fit el-table--enable-row-hover el-table--enable-row-transition'>
            <thead class="el-table__header-wrapper">
              <tr>
                <th>周1</th>
                <th>周2</th>
                <th>周3</th>
                <th>周4</th>
                <th>周5</th>
                <th>周6</th>
                <th>周7</th>
              </tr>
            </thead>
            <tbody class="el-table__body">
              <tr v-for="(trrow, trindex) in s_calendar">
                <td v-for="(row, status) in trrow" :style="{color:row.background}">
                  <p>
                    {{row.date_title}}
                  </p>
                  <p>
                    {{row.lunar}}
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
        </el-col>
        <el-col :span="14" :xs="24">
          <div class="form-unit">
            <span class="mvc-title-left"> 设置时间应用范围 </span>
          </div>
          <el-button @click="gotoPage('/ruoyi/system/post/index')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <el-button @click="popTestTime('')" type='primary' size="mini">时间测试</el-button>
          <el-button @click="popWorkTimeTest('')" type='primary' size="mini">时间单独测试</el-button>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始时间" prop="">
                  {{getTimeString(t_month,'month_betime')}}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="结束时间" prop="">
                  {{getTimeString(t_month,'month_entime')}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="popTimeApply('')" type='success' size="mini"><i class='fa fa-edit'></i>修改应用范围</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 工作时间 </span>
          </div>
          <el-table :data="s_worktime">
            <el-table-column label="开始时间" prop="start_hour">
            </el-table-column>
            <el-table-column label="结束时间" prop="end_hour">
            </el-table-column>
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_worktime('&CMIDtimeid4='+scope.row.timeid+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
          </el-table>
          <el-button @click="popWorktimeManage('')" type='success' size="mini"><i class='fa fa-plus'></i>增加工作时间</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 星期设置 </span>
          </div>
          <el-table :data="s_week">
            <el-table-column label="星期" prop="name">
            </el-table-column>
          </el-table>
          <el-button @click="popWeekModify('')" type='success' size="mini"><i class='fa fa-edit'></i>修改星期</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 节假日设置 </span>
          </div>
          <el-table :data="s_holid">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_holid('&CMIDid4='+scope.row.id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popHoliUpdate('&CMIDid='+scope.row.id+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="节假日" prop="name">
            </el-table-column>
            <el-table-column label="日期" prop="solar_time">
              <template slot-scope="scope">
                {{getTimeString(scope.row,'solar_time')}}
              </template>
            </el-table-column>
          </el-table>
          <el-button @click="popHoliInputTwo('')" type='success' size="mini"><i class='fa fa-plus'></i>增加节假日</el-button>
        </el-col>
      </el-row>
    </el-form>
    <el-dialog :visible.sync="TestTimeVisible" append-to-body>
      <TestTime v-if="TestTimeVisible" ref="TestTime" :popparams="popparams"> </TestTime>
    </el-dialog>
    <el-dialog :visible.sync="WorkTimeTestVisible" append-to-body>
      <WorkTimeTest v-if="WorkTimeTestVisible" ref="WorkTimeTest" :popparams="popparams"> </WorkTimeTest>
    </el-dialog>
    <el-dialog :visible.sync="TimeApplyVisible" append-to-body>
      <TimeApply v-if="TimeApplyVisible" ref="TimeApply" :popparams="popparams"> </TimeApply>
    </el-dialog>
    <el-dialog :visible.sync="WorktimeManageVisible" append-to-body>
      <WorktimeManage v-if="WorktimeManageVisible" ref="WorktimeManage" :popparams="popparams"> </WorktimeManage>
    </el-dialog>
    <el-dialog :visible.sync="WeekModifyVisible" append-to-body>
      <WeekModify v-if="WeekModifyVisible" ref="WeekModify" :popparams="popparams"> </WeekModify>
    </el-dialog>
    <el-dialog :visible.sync="HoliUpdateVisible" append-to-body>
      <HoliUpdate v-if="HoliUpdateVisible" ref="HoliUpdate" :popparams="popparams"> </HoliUpdate>
    </el-dialog>
    <el-dialog :visible.sync="HoliInputTwoVisible" append-to-body>
      <HoliInputTwo v-if="HoliInputTwoVisible" ref="HoliInputTwo" :popparams="popparams"> </HoliInputTwo>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import TestTime from "@/views/oa/system/TestTime";
  import WorkTimeTest from "@/views/oa/system/WorkTimeTest";
  import TimeApply from "@/views/oa/system/TimeApply";
  import WorktimeManage from "@/views/oa/system/WorktimeManage";
  import WeekModify from "@/views/oa/system/WeekModify";
  import HoliUpdate from "@/views/oa/system/HoliUpdate";
  import HoliInputTwo from "@/views/oa/system/HoliInputTwo";
  export default {
    name: 'TimeInsert',
    components: {
      TestTime,
      WorkTimeTest,
      TimeApply,
      WorktimeManage,
      WeekModify,
      HoliUpdate,
      HoliInputTwo,
    },
    props: ['popparams'],
    data() {
      return {
        TestTimeVisible: false,
        TestTimeValue: null,
        TestTimeDesc: null,
        WorkTimeTestVisible: false,
        WorkTimeTestValue: null,
        WorkTimeTestDesc: null,
        TimeApplyVisible: false,
        TimeApplyValue: null,
        TimeApplyDesc: null,
        WorktimeManageVisible: false,
        WorktimeManageValue: null,
        WorktimeManageDesc: null,
        WeekModifyVisible: false,
        WeekModifyValue: null,
        WeekModifyDesc: null,
        HoliUpdateVisible: false,
        HoliUpdateValue: null,
        HoliUpdateDesc: null,
        HoliInputTwoVisible: false,
        HoliInputTwoValue: null,
        HoliInputTwoDesc: null,
        vueparams: this.getVUEParams(""),
        s_search: {},
        s_calendar: [],
        t_month: {
          month_betime: null,
          month_entime: null,
        },
        s_worktime: [],
        s_week: [],
        s_holid: [],
        s_year: [],
        s_month: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/system/TimeInsert/timeInsert?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_holid(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/system/TimeInsert/d_holid?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_worktime(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/system/TimeInsert/d_worktime?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_worktime_day(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/system/TimeInsert/d_worktime_day?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      list_s_year(value) {
        if (this.$route.fullPath.indexOf("?") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "?CMIDSEL1=" + value);
        } else if (this.$route.fullPath.indexOf("CMIDSEL1=") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "&CMIDSEL1=" + value);
        } else {
          this.gotoPage("/redirect/oa/system/TimeInsert?" + this.vueparams, {
            CMIDSEL1: value
          });
        }
      },
      list_s_month(value) {
        if (this.$route.fullPath.indexOf("?") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "?CMIDSEL2=" + value);
        } else if (this.$route.fullPath.indexOf("CMIDSEL2=") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "&CMIDSEL2=" + value);
        } else {
          this.gotoPage("/redirect/oa/system/TimeInsert?" + this.vueparams, {
            CMIDSEL2: value
          });
        }
      },
      popTestTime(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.TestTimeVisible = !this.TestTimeVisible;
      },
      popWorkTimeTest(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.WorkTimeTestVisible = !this.WorkTimeTestVisible;
      },
      popTimeApply(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.TimeApplyVisible = !this.TimeApplyVisible;
      },
      popWorktimeManage(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.WorktimeManageVisible = !this.WorktimeManageVisible;
      },
      popWeekModify(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.WeekModifyVisible = !this.WeekModifyVisible;
      },
      popHoliUpdate(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.HoliUpdateVisible = !this.HoliUpdateVisible;
      },
      popHoliInputTwo(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.HoliInputTwoVisible = !this.HoliInputTwoVisible;
      },
    },
  }
</script>
